﻿// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "ShaderLearn/C_11_3_BillBoard" {
	Properties {
		_Color ("Color", Color) = (1,1,1,1)
		_MainTex ("Albedo (RGB)", 2D) = "white" {}
		_VerticalBillBoard("Vertical BillBoard",Range(0, 1) ) = 1
	}
	SubShader {
		Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent"
			"DisableBatching" = "True" }
		Pass
		{
			Tags{ "LightMode" = "ForwardBase" }
			ZWrite off
			//Blend SrcAlpha OneMinusSrcAlpha
			Blend One One

			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag

#include "UnityLightingCommon.cginc"
#include "UnityCG.cginc"

			fixed4 _Color;
			sampler2D _MainTex;
			float4 _MainTex_ST;
			float _VerticalBillBoard;

			struct a2v
			{
				float4 vertex : POSITION;
				float4 texcoord : TEXCOORD0;
			};

			struct v2f
			{
				float4 vertex : SV_POSITION;
				float2 uv : TEXCOORD2;
			};

			v2f vert(a2v v)
			{
				v2f o;
				o.vertex = UnityObjectToClipPos(v.vertex);
				o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
				return o;
			}

			fixed4 frag(v2f i) : SV_Target
			{
				fixed3 albedo = tex2D(_MainTex, i.uv).rgb * _Color.rgb;
				fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz * albedo;

				return fixed4(ambient, 1.0);
			}

			ENDCG
		}
	} 
	FallBack "Transparent/VertexLit"
}
